<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<h1>文件上传测试</h1>
<a href="/upload.html">上传页面</a>
<hr>
<div>
    <h2>微博列表</h2>
    <div v-for="weibo in arr">
        <h3>{{weibo.content}}</h3>
        <p>{{weibo.created}}</p>
        <img :src="weibo.url" width="100" alt="">
        <a href="javascript:void(0)" @click="del(weibo.id)">删除</a>
    </div>
</div>
<!-- import Vue before Element -->
<script src="https://cdn.bootcdn.net/ajax/libs/axios/0.21.1/axios.min.js"></script>
<!-- import JavaScript -->
<script src="https://cdn.staticfile.org/vue/2.2.2/vue.min.js"></script>
<script>
    let v = new Vue({
        el: 'body>div',
        data: {
            arr: []
        },
        methods: {
            del(id) {
                if (confirm("您确认删除此条微博吗?")) {
                    //异步删除请求
                    axios.get("/delete?id=" + id).then(function (response) {
                        //刷新页面
                        location.reload();
                    })
                }

            }
        },
        created: function () {
            //发请求获取所有微博信息
            axios.get("/select").then(function (response) {
                v.arr = response.data;
            })
        }
    })
</script>
</body>
</html>